 /*   select 'select ''' || REPLACE(REPLACE(a.table_name,'UV_PG',''),'_MOLI','') || ''' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from ' || a.table_name || ' g union all' vals
    from user_tab_columns a
    where a.table_name  LIKE 'UV_PG%_MOLI'
    GROUP BY a.table_name
    ORDER BY 1   */
/*SELECT * FROM erp_mli.vrt_grillestd v, outils_mli.gen_date d WHERE d.enreg_id=v.enreg_id and d.dat_typ='TRF'*/

call   uvse_existsorcreate('VRT_GRILLESTD')  ;



/*SELECT enreg_id, grille_cod, grillecle_cod, enreg_s, grillestd_lib,grillestd_lib2,grillestd_rang,regroup_cod,poids_val FROM (
    SELECT * FROM SE_VRT_GRILLESTD
    minus
    SELECT * FROM erp_mli.vrt_grillestd
)
ORDER BY 1,3 */


INSERT INTO  SE_VRT_GRILLESTD vv (enreg_id, grille_cod, grillecle_cod, enreg_s, grillestd_lib,grillestd_lib2,grillestd_rang,regroup_cod,poids_val)

(SELECT Nvl((SELECT v.enreg_id FROM  erp_mli.VRT_GRILLESTD v WHERE v.grille_cod=gs.grille_cod AND v.grillecle_cod=REPLACE(REPLACE(gs.id,'.',''),'+','_')),0)
      ,grille_cod
      ,(REPLACE(REPLACE(id,'.',''),'+','_')) grillecle_cod
      ,'N' enreg_s
      ,Nvl(LIBELLE,'.') grillestd_lib
      ,NULL grillestd_lib2
      ,1 grillestd_rang
      ,REGRSTAT regroup_cod
      ,(SELECT v.poids_val FROM  erp_mli.VRT_GRILLESTD v WHERE v.grille_cod=gs.grille_cod AND v.grillecle_cod=REPLACE(REPLACE(gs.id,'.',''),'+','_')) poids_val
FROM
   (

        select 'ARM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGARM_MOLI g union all
        select 'ARPA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGARPA_MOLI g union all
        select 'BIGAMME' grille_cod,ID,LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGBIGAMME_MOLI g union all
        select 'BIMARCHE' grille_cod,ID,LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGBIMARCHE_MOLI g union all
        select 'BIREGRTYPEC' grille_cod,ID,LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGBIREGRTYPEC_MOLI g union all
        select 'BMO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGBMO_MOLI g union all
        select 'BOC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGBOC_MOLI g union all
        select 'BRL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGBRL_MOLI g union all
        select 'CAR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGCAR_MOLI g union all
        select 'CHO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGCHO_MOLI g union all
        select 'CLEN' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGCLEN_MOLI g union all
        select 'CLO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGCLO_MOLI g union all
        select 'CPA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGCPA_MOLI g union all
        select 'CUN' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGCUN_MOLI g union all
        select 'DAR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDAR_MOLI g union all
        select 'DBC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDBC_MOLI g union all
        select 'DBO' grille_cod,ID,ID LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGDBO_MOLI g union all
        select 'DEG' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDEG_MOLI g union all
        select 'DENC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDENC_MOLI g union all
        select 'DES' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDES_MOLI g union all
        select 'DET' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDET_MOLI g union all
        select 'DIA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDIA_MOLI g union all
        select 'DIEM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDIEM_MOLI g union all
        select 'DIM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDIM_MOLI g union all
        select 'DIPA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDIPA_MOLI g union all
        select 'DIPB' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDIPB_MOLI g union all
        select 'DMA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDMA_MOLI g union all
        select 'DPB' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDPB_MOLI g union all
        select 'DPC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDPC_MOLI g union all
        select 'DPP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDPP_MOLI g union all
        select 'DQI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDQI_MOLI g union all
        select 'DRT' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGDRT_MOLI g union all
        select 'EAU' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGEAU_MOLI g union all
        select 'EIP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGEIP_MOLI g union all
        select 'ENC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGENC_MOLI g union all
        select 'ENCA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGENCA_MOLI g union all
        select 'EPA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGEPA_MOLI g union all
        select 'FBA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGFBA_MOLI g union all
        select 'FBO' grille_cod,ID,ID LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGFBO_MOLI g union all
        select 'FCU' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGFCU_MOLI g union all
        select 'FENC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGFENC_MOLI g union all
        select 'FPC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGFPC_MOLI g union all
        select 'FPP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGFPP_MOLI g union all
        select 'FTE' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGFTE_MOLI g union all
        select 'KIT' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGKIT_MOLI g union all
        select 'KPK' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGKPK_MOLI g union all
        select 'LAI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLAI_MOLI g union all
        select 'LAM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLAM_MOLI g union all
        select 'LAN' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLAN_MOLI g union all
        select 'LAR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLAR_MOLI g union all
        select 'LBC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLBC_MOLI g union all
        select 'LBJ' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLBJ_MOLI g union all
        select 'LBM' grille_cod,ID,id LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGLBM_MOLI g union all
        select 'LBP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLBP_MOLI g union all
        select 'LBR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLBR_MOLI g union all
        select 'LBV' grille_cod,ID,id LIBELLE,CHECKSUM,REGRSTAT from UV_PGLBV_MOLI g union all
        select 'LEL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLEL_MOLI g union all
        select 'LGL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLGL_MOLI g union all
        select 'LMA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLMA_MOLI g union all
        select 'LMQ' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLMQ_MOLI g union all
        select 'LOC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLOC_MOLI g union all
        select 'LPA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLPA_MOLI g union all
        select 'LPC' grille_cod,ID,id LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGLPC_MOLI g union all
        select 'LPP' grille_cod,ID,id LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGLPP_MOLI g union all
        select 'LPS' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGLPS_MOLI g union all
        select 'MAC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMAC_MOLI g union all
        select 'MAF' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMAF_MOLI g union all
        select 'MAI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMAI_MOLI g union all
        select 'MAM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMAM_MOLI g union all
        select 'MAR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMAR_MOLI g union all
        select 'MARP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMARP_MOLI g union all
        select 'MAT' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMAT_MOLI g union all
        select 'MBC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMBC_MOLI g union all
        select 'MBO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMBO_MOLI g union all
        select 'MBR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMBR_MOLI g union all
        select 'MEL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMEL_MOLI g union all
        select 'MEMB' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMEMB_MOLI g union all
        select 'MFI' grille_cod,ID,ID LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGMFI_MOLI g union all
        select 'MOD' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMOD_MOLI g union all
        select 'MOMA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMOMA_MOLI g union all
        select 'MOPA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMOPA_MOLI g union all
        select 'MOV' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMOV_MOLI g union all
        select 'MPC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMPC_MOLI g union all
        select 'MPP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGMPP_MOLI g union all
        select 'NBR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGNBR_MOLI g union all
        select 'NCO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGNCO_MOLI g union all
        select 'NES' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGNES_MOLI g union all
        select 'NFI' grille_cod,ID,id LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGNFI_MOLI g union all
        select 'NMA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGNMA_MOLI g union all
        select 'OCF' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGOCF_MOLI g union all
        select 'OEI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGOEI_MOLI g union all
        select 'OEL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGOEL_MOLI g union all
        select 'ORI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGORI_MOLI g union all
        select 'PAD' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGPAD_MOLI g union all
        select 'PAS' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGPAS_MOLI g union all
        select 'PBD' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGPBD_MOLI g union all
        select 'PBR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGPBR_MOLI g union all
        select 'PIPB' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGPIPB_MOLI g union all
        select 'POS' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGPOS_MOLI g union all
        select 'PPR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGPPR_MOLI g union all
        select 'PRB' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGPRB_MOLI g union all
        select 'PTO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGPTO_MOLI g union all
        select 'QAC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQAC_MOLI g union all
        select 'QAP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQAP_MOLI g union all
        select 'QBC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQBC_MOLI g union all
        select 'QBO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQBO_MOLI g union all
        select 'QBR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQBR_MOLI g union all
        select 'QCO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQCO_MOLI g union all
        select 'QEA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQEA_MOLI g union all
        select 'QEC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQEC_MOLI g union all
        select 'QEM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQEM_MOLI g union all
        select 'QEN' grille_cod,ID,id LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGQEN_MOLI g union all
        select 'QET' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQET_MOLI g union all
        select 'QFI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQFI_MOLI g union all
        select 'QFL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQFL_MOLI g union all
        select 'QGL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQGL_MOLI g union all
        select 'QMA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQMA_MOLI g union all
        select 'QMR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQMR_MOLI g union all
        select 'QPA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQPA_MOLI g union all
        select 'QPB' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQPB_MOLI g union all
        select 'QQI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQQI_MOLI g union all
        select 'QRF' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQRF_MOLI g union all
        select 'QRP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQRP_MOLI g union all
        select 'QRT' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQRT_MOLI g union all
        select 'QTI' grille_cod,ID,id LIBELLE,CHECKSUM,REGRSTAT from UV_PGQTI_MOLI g union all
        select 'QVI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGQVI_MOLI g union all
        select 'RAI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGRAI_MOLI g union all
        select 'REP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGREP_MOLI g union all
        select 'RMA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGRMA_MOLI g union all
        select 'SAC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSAC_MOLI g union all
        select 'SBC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSBC_MOLI g union all
        select 'SBM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSBM_MOLI g union all
        select 'SCC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSCC_MOLI g union all
        select 'SCO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSCO_MOLI g union all
        select 'SEC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSEC_MOLI g union all
        select 'SEN' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSEN_MOLI g union all
        select 'SFM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSFM_MOLI g union all
        select 'SGL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSGL_MOLI g union all
        select 'SPR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSPR_MOLI g union all
        select 'SUB' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSUB_MOLI g union all
        select 'SYPA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGSYPA_MOLI g union all
        select 'TAM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTAM_MOLI g union all
        select 'TART' grille_cod,ID,id LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGTART_MOLI g union all
        select 'TBA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTBA_MOLI g union all
        select 'TBM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTBM_MOLI g union all
        select 'TBV' grille_cod,ID,id LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGTBV_MOLI g union all
        select 'TCLO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTCLO_MOLI g union all
        select 'TCO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTCO_MOLI g union all
        select 'TEC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTEC_MOLI g union all
        select 'TED' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTED_MOLI g union all
        select 'TEL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTEL_MOLI g union all
        select 'TEM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTEM_MOLI g union all
        select 'TEMB' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTEMB_MOLI g union all
        select 'TEMP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTEMP_MOLI g union all
        select 'TENC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTENC_MOLI g union all
        select 'TET' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTET_MOLI g union all
        select 'TFE' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTFE_MOLI g union all
        select 'TFI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTFI_MOLI g union all
        select 'TFM' grille_cod,ID,id LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGTFM_MOLI g union all
        select 'TGL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTGL_MOLI g union all
        select 'TIS' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTIS_MOLI g union all
        select 'TLA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTLA_MOLI g union all
        select 'TLO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTLO_MOLI g union all
        select 'TMA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTMA_MOLI g union all
        select 'TNES' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTNES_MOLI g union all
        select 'TON' grille_cod,ID,id LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGTON_MOLI g union all
        select 'TOU' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTOU_MOLI g union all
        select 'TOUC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTOUC_MOLI g union all
        select 'TPA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTPA_MOLI g union all
        select 'TPC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTPC_MOLI g union all
        select 'TPL' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTPL_MOLI g union all
        select 'TPM' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTPM_MOLI g union all
        select 'TPO' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTPO_MOLI g union all
        select 'TPP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTPP_MOLI g union all
        select 'TPR' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTPR_MOLI g union all
        select 'TPRB' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTPRB_MOLI g union all
        select 'TRA' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTRA_MOLI g union all
        select 'TRE' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTRE_MOLI g union all
        select 'TREP' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTREP_MOLI g union all
        select 'TRF' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTRF_MOLI g union all
        select 'TRT' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTRT_MOLI g union all
        select 'TRV' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTRV_MOLI g union all
        select 'TSEC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTSEC_MOLI g union all
        select 'TTE' grille_cod,ID,id LIBELLE,CHECKSUM,NULL REGRSTAT from UV_PGTTE_MOLI g union all
        select 'TVI' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTVI_MOLI g union all
        select 'TXET' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGTXET_MOLI g union all
        select 'VIC' grille_cod,ID,LIBELLE,CHECKSUM,REGRSTAT from UV_PGVIC_MOLI g


          )   gs
WHERE id !='.'
  AND REPLACE(REPLACE(id,'.',''),'+','_') IS NOT null
  AND EXISTS (SELECT 1 FROM erp_mli.vrt_grille ggg WHERE ggg.grille_cod=gs.grille_cod));


UPDATE se_vrt_grillestd SET enreg_id = outils_mli.enreg_id.NEXTVAL WHERE enreg_id=0 ;



call  uvse_synchroverserp ('enreg_id','VRT_GRILLESTD','O')  ;

commit;
